class noticeModel{
  constructor(){
    this.db = require('../../config/db')
  }

  //获取所有公告信息
  noticeInfo(){
    let sql = 'select * from notice ORDER BY pubdate DESC'
    return this.db.query(sql)
  }
  //获取最新公告信息
  notice(){
    let sql = 'select * from notice order by pubdate DESC limit 0,1'
    return this.db.query(sql)
  }
  
  //公告分页信息
  pageNotice(pagenum,per_page){
    let sql = 'select * from notice order by pubdate DESC limit ?,?'
    return this.db.query(sql,[pagenum,per_page])
  }
  
  //添加公告
  addNotice(content,author){
    let sql = 'insert into notice (content,author) values(?,?)'
    return this.db.query(sql,[content,author])
  }
}

module.exports = new noticeModel()